<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .p {
            width: 300px;
            height: 200px;
            background-color: lightblue;
        }
        .box {
            width: 200px;
            height: 100px;
            background-color: lightgreen;
        }
    </style>
</head>
<body>
    <div class="p">
        <div class="box"></div>
        <hr>
        <button id="btn-dbl">双击事件</button>
    </div>
    <script>
        var btnDbl = document.querySelector('#btn-dbl')
        var p = document.querySelector('.p')
        var box = p.querySelector('.box')
        btnDbl.ondblclick = function () {
            console.log('双击事件被触发了');
        }

        // 注册鼠标经过事件: 收到事件冒泡的影响
        p.onmouseover = function () {
            console.log('p onmouseover');
        }
        // 注册鼠标离开: 会受到事件冒泡的影响
        p.onmouseout = function () {
            console.log('p onmouseout');
        }

        // 注册鼠标进入事件: 不会受到事件冒泡的影响
        p.onmouseenter = function () {
            console.log('p onmouseenter');
        }
        // 注册鼠标离开: 不会受到事件冒泡的影响
        p.onmouseleave = function () {
            console.log('p onmouseleave');
        }
    </script>
</body>

</html>